package codeforces23;

import java.util.Scanner;

/**
 * Codeforces 23. Problem B
 * 
 * @author Aleksandr Nikiforov
 */
public class ProblemB {

	public static void main(String[] args) {
		ProblemB problem = new ProblemB();
		problem.solve();
	}

	private void solve() {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for (int i = 0; i < T; i++) {
			int n = sc.nextInt();
			if (n <= 2) {
				System.out.println(0);
			} else {
				System.out.println(n - 2);
			}
		}
	}

}
